// vim:ft=javascript

ARG_WITH("dom", "DOM support", "yes");

if (PHP_DOM == "yes") {
	if (PHP_LIBXML == "yes" &&
		ADD_EXTENSION_DEP('dom', 'libxml') &&
		CHECK_HEADER_ADD_INCLUDE("libxml/parser.h", "CFLAGS_DOM", PHP_PHP_BUILD + "\\include\\libxml2")
	) {
		EXTENSION("dom", "php_dom.c attr.c document.c infra.c \
			xml_document.c html_document.c xml_serializer.c html5_serializer.c html5_parser.c namespace_compat.c private_data.c \
			domexception.c processinginstruction.c \
			cdatasection.c documentfragment.c domimplementation.c element.c inner_outer_html_mixin.c \
			node.c characterdata.c documenttype.c \
			entity.c nodelist.c html_collection.c text.c comment.c \
			entityreference.c \
			token_list.c \
			notation.c obj_map.c xpath.c dom_iterators.c \
			namednodemap.c xpath_callbacks.c", null, "/I ext/lexbor");

		ADD_EXTENSION_DEP('dom', 'lexbor');

		ADD_SOURCES("ext/dom/parentnode", "tree.c css_selectors.c", "dom");
		ADD_SOURCES("ext/dom/lexbor/selectors-adapted", "selectors.c", "dom");

		AC_DEFINE("HAVE_DOM", 1, "Define to 1 if the PHP extension 'dom' is available.");

		if (!PHP_DOM_SHARED) {
			ADD_FLAG("CFLAGS_DOM", "/D LIBXML_STATIC /D LEXBOR_STATIC ");
		} else {
			if (!CHECK_LIB("libxml2.lib", "dom")) {
				WARNING("dom support can't be enabled, libxml is not found")
			}
		}
		PHP_INSTALL_HEADERS("ext/dom",
			"dom_ce.h " +
			"namespace_compat.h " +
			"xml_common.h " +
			"xpath_callbacks.h " +
			"lexbor/selectors-adapted/selectors.h "
		);
	} else {
		WARNING("dom support can't be enabled, libxml is not enabled")
		PHP_DOM = "no"
	}
}
